﻿using Nemerle.Collections;
using Nemerle.Text;
using Nemerle.Utility;

using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using NRails;
using NRails.Database;
using BLToolkit.Data;
using BLToolkit.Data.Sql;

namespace NRails.Tests
{
  /// <summary>
  /// Description of EngineTests.
  /// </summary>
  public class EngineTests: AssertionHelper
  {
      [Test]
      public SchemaProviderTest() : void
      {
          def cfg = ConfigurationTests.TestConfiguration;
          Expect(cfg, Is.Not.Null);
          def engine = Engine(cfg);
          Expect(engine.Cfg, Is.Not.Null);
          def schema = engine.GetSchema();
          def schema2 = engine.GetSchema();
          Expect(schema2, Is.SameAs(schema));
          
          def db = DbManager(cfg.ConnectionStringName);
          def dataProvider =  db.DataProvider;
          def sqlProvider = dataProvider.CreateSqlProvider();
          Console.WriteLine(sqlProvider.ConvertExpression(SqlValue(DateTime.Now)));
          Console.WriteLine(sqlProvider.ConvertExpression(SqlValue(1)));
          Console.WriteLine(sqlProvider.ConvertExpression(SqlValue("123123")));
          Console.WriteLine(sqlProvider.ConvertExpression(SqlValue(1.56677)));
      }
  }
}
